home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / win-os2.swg / 0040_Windows Delay.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-08-25  |  879 b   |  33 lines

  1. {
  2. Here a small BPW source which implements a Delay(ms : Word); just like
  3. in the DOS version. Limitations are that only a minimum delay is
  4. guaranteed, so timing is not exact. This is due to the task switching
  5. nature of windows which makes it impossible to generate accurate delays.
  6. For large values it's however quite good.
  7.  
  8. The timer used has msec accuracy and has overflow every 49 days (if
  9. windows lasts that long in one session.
  10. }
  11.  
  12. Uses
  13.   Winprocs;
  14.  
  15. Procedure Delay(ms : Word);
  16.  
  17. Var
  18.   theend,
  19.   marker  : Longint;
  20.  
  21. Begin
  22. {----Potential overflow if windows runs for 49 days without a stop}
  23.   marker:=GetTickCount;
  24. {$R-}
  25.   theend:=Longint(marker+ms);
  26. {$R+}
  27. {----First see if timer overrun will occur and wait for it. Then test as
  28. usual}
  29.   If (theend<marker)
  30.     Then While (GetTickCount>=0) DO;
  31.   While (theend>GettickCount) Do;
  32. End; {of Delay}
  33.